// powrspiral.txt. Use it to deactivate it. If player has enough Mechanics skill,
// it just turns off. Otherwise, it explodes.
// Cell 0 - Mechanics skill to deactivate it.
// Cell 1,2 - Stuff done flag which is set to 1 when it is off.
// Cell 3 - Num of d10 explosion does. Defaults to 12.
// Cell 4 - vulnerable to control key. If 1, having control key makes it just shut off.
// Cell 5 - cant turn it off without mechanics skill at least 2 less than difficulty

beginobjectscript;

variables;
short cur_tick;
short r1;
short exploding = 0;
short damage = 0;
short warned_once = 0;

body;

beginstate INIT_STATE;
	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; 
		if (gf(54,13) == 0) {
			if (get_ran(1,0,100) < 40)
				create_text_bubble("Hummmm ...");
			
			//if (get_ran(1,0,100) < 40)
			//	run_sparkles_on_object(ME,17,5,1);							
			}
	
	cur_tick = get_current_tick();
	if (gf(55,13) > 0)
		set_state(5);
	
break;

beginstate 5;
	create_text_bubble("Spark! Hiss!");
	if (cur_tick != get_current_tick()) {
		cur_tick = get_current_tick();
		set_state(6);
		}
break;

beginstate 6;
	create_text_bubble("Smoke! Spark!");
	if (cur_tick != get_current_tick()) {
		cur_tick = get_current_tick();
		set_state(7);
		}
break;

beginstate 7;
	set_flag(55,14,1);

	play_sound(103);
		
	r1 = 2000 + get_ran(1,0,1000);
	damage_nearby(r1,8,1,2);
	spray_missiles(58,8,8);

	kill_object(ME,0);
	
	set_terrain(58,38,90);
	set_terrain(58,39,91);
	set_terrain(58,40,91);
	set_terrain(59,38,91);
	set_terrain(59,39,90);
	set_terrain(59,40,90);
	set_terrain(52,37,204);
	
	damage_char(24,1500 + get_ran(1,0,1500),0);
	
	begin_talk_mode(84);
break;

beginstate USE_STATE;
	begin_talk_mode(80);

break;
